Skip to content

Add history propagation#1025

Merged
acroca merged 3 commits into
dapr:mainfrom
acroca:history-propagation
May 15, 2026
Merged

Add history propagation#1025
acroca merged 3 commits into
dapr:mainfrom
acroca:history-propagation

Conversation

@acroca
Copy link
Copy Markdown
Member

@acroca acroca commented May 12, 2026

Description

Adds workflow history propagation to dapr-ext-workflow.

A workflow can opt into propagating its execution history to a child workflow or activity via propagation=PropagationScope.OWN_HISTORY or propagation=PropagationScope.LINEAGE on call_activity / call_child_workflow.

The receiver reads the propagated chunk through ctx.get_propagated_history() and queries it with PropagatedHistory.get_workflow_by_name(...)WorkflowResult.get_activity_by_name(...) / .get_child_workflow_by_name(...).

Public surface lives in dapr.ext.workflow.propagation and is re-exported from dapr.ext.workflow — users never need to import from _durabletask. Default behavior is unchanged: propagation=None propagates nothing.

Requires a Dapr sidecar built with history propagation support (durabletask-go #85+ / runtime 1.18+). Against an older sidecar the propagation field is silently dropped and get_propagated_history() returns None.

Includes an example app at examples/workflow/history_propagation.py.

References

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 71.14504% with 189 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.88%. Comparing base (bffb749) to head (cb492fa).
⚠️ Report is 128 commits behind head on main.

Files with missing lines Patch % Lines
.../_durabletask/internal/orchestrator_service_pb2.py 1.61% 61 Missing ⚠️
...rkflow/_durabletask/internal/history_events_pb2.py 3.44% 56 Missing ⚠️
...orkflow/_durabletask/internal/orchestration_pb2.py 4.00% 24 Missing ⚠️
.../_durabletask/internal/orchestrator_actions_pb2.py 4.54% 21 Missing ⚠️
.../workflow/_durabletask/internal/attestation_pb2.py 42.85% 16 Missing ⚠️
...dapr-ext-workflow/dapr/ext/workflow/propagation.py 96.37% 5 Missing ⚠️
...-workflow/dapr/ext/workflow/_durabletask/worker.py 75.00% 3 Missing ⚠️
...xt-workflow/dapr/ext/workflow/_durabletask/task.py 88.88% 1 Missing ⚠️
...ext-workflow/dapr/ext/workflow/workflow_context.py 75.00% 1 Missing ⚠️
...kflow/tests/durabletask/test_propagation_wiring.py 98.94% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1025      +/-   ##
==========================================
- Coverage   86.63%   81.88%   -4.75%     
==========================================
  Files          84      141      +57     
  Lines        4473    13983    +9510     
==========================================
+ Hits         3875    11450    +7575     
- Misses        598     2533    +1935     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acroca acroca force-pushed the history-propagation branch from f492eed to 4e5a9ad Compare May 13, 2026 12:08
Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca acroca force-pushed the history-propagation branch from 4e5a9ad to 53cc107 Compare May 13, 2026 12:22
@acroca acroca marked this pull request as ready for review May 13, 2026 12:48
@acroca acroca requested review from a team as code owners May 13, 2026 12:48
Comment thread examples/workflow/README.md Outdated
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py Outdated
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py Outdated
Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca acroca requested a review from seherv May 15, 2026 08:38
Copy link
Copy Markdown
Contributor

@CasperGN CasperGN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @acroca

@acroca acroca added this pull request to the merge queue May 15, 2026
Merged via the queue into dapr:main with commit d577d20 May 15, 2026
13 of 15 checks passed
@nelson-parente nelson-parente added this to the v1.18 milestone May 20, 2026
sicoyle pushed a commit to GHX5T-SOL/python-sdk that referenced this pull request May 26, 2026
* feat(workflow): align history propagation API with go-sdk

Cassie (durabletask-go author) flagged divergence between python-sdk dapr#1025
and the freshly-renamed go-sdk helpers in durabletask-go dapr#105 (merged
2026-05-19, after dapr#1025 landed). This brings python-sdk's surface back
in line for cross-SDK parity before 1.18 ships.

Read API renames (mirror durabletask-go GetLast*ByName):
- PropagatedHistory.get_workflow_by_name      -> get_last_workflow_by_name
- WorkflowResult.get_activity_by_name         -> get_last_activity_by_name
- WorkflowResult.get_child_workflow_by_name   -> get_last_child_workflow_by_name

Plural variants (get_workflows_by_name, get_activities_by_name,
get_child_workflows_by_name) and the chain-level helpers are unchanged.

Scheduling helpers (mirror go-sdk workflow.PropagateLineage /
workflow.PropagateOwnHistory):
- propagate_lineage()      -> PropagationScope.LINEAGE
- propagate_own_history()  -> PropagationScope.OWN_HISTORY

PropagationScope enum is kept as the underlying value, so both
`propagation=propagate_lineage()` and
`propagation=PropagationScope.LINEAGE` work.

Example, README snippet, and tests updated to use the renamed/new
surface. No runtime/proto changes.

Refs: dapr#1001, dapr/durabletask-go#105, dapr/go-sdk#823
Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>

* refactor(workflow): drop propagate_lineage/propagate_own_history factories

Per review feedback, Go-style factory helpers are not idiomatic Python: they
obscure the actual enum value at the call site and confuse static type
checkers (return annotation only shows PropagationScope, not the specific
member). Use PropagationScope.LINEAGE / PropagationScope.OWN_HISTORY
directly instead.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>

---------

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
sicoyle added a commit that referenced this pull request May 28, 2026
)

* feat(workflow): align history propagation API with go-sdk

Cassie (durabletask-go author) flagged divergence between python-sdk #1025
and the freshly-renamed go-sdk helpers in durabletask-go #105 (merged
2026-05-19, after #1025 landed). This brings python-sdk's surface back
in line for cross-SDK parity before 1.18 ships.

Read API renames (mirror durabletask-go GetLast*ByName):
- PropagatedHistory.get_workflow_by_name      -> get_last_workflow_by_name
- WorkflowResult.get_activity_by_name         -> get_last_activity_by_name
- WorkflowResult.get_child_workflow_by_name   -> get_last_child_workflow_by_name

Plural variants (get_workflows_by_name, get_activities_by_name,
get_child_workflows_by_name) and the chain-level helpers are unchanged.

Scheduling helpers (mirror go-sdk workflow.PropagateLineage /
workflow.PropagateOwnHistory):
- propagate_lineage()      -> PropagationScope.LINEAGE
- propagate_own_history()  -> PropagationScope.OWN_HISTORY

PropagationScope enum is kept as the underlying value, so both
`propagation=propagate_lineage()` and
`propagation=PropagationScope.LINEAGE` work.

Example, README snippet, and tests updated to use the renamed/new
surface. No runtime/proto changes.

Refs: #1001, dapr/durabletask-go#105, dapr/go-sdk#823


* refactor(workflow): drop propagate_lineage/propagate_own_history factories

Per review feedback, Go-style factory helpers are not idiomatic Python: they
obscure the actual enum value at the call site and confuse static type
checkers (return annotation only shows PropagationScope, not the specific
member). Use PropagationScope.LINEAGE / PropagationScope.OWN_HISTORY
directly instead.



---------


(cherry picked from commit 2fd3237)

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com>
Co-authored-by: Nelson Parente <nelson_parente@live.com.pt>
Co-authored-by: Sam <sam@diagrid.io>
nelson-parente added a commit to nelson-parente/quickstarts that referenced this pull request May 28, 2026
Aligns the Python workflow history propagation quickstart with Cassie's
canonical Go version that merged into release-1.18
(dapr#1315, tutorials/workflow/go/history-propagation).

Changes to match the canonical structure:

- Move from workflows/python/sdk-context-propagation/order-processor/ to
  tutorials/workflow/python/history-propagation/, matching the Go sibling
  at tutorials/workflow/go/history-propagation/
- Split the monolithic app.py into app.py / workflow.py / models.py,
  mirroring main.go / workflow.go / models.go
- Add ForwardLineage flag to PatientRecord and run both scenarios
  back-to-back (happy path + negative), purging state after each so the
  app exits on its own
- Make DispenseMedication refuse to dispense when no propagated history
  is received, returning a refused DispenseResult with a Reason field
- Match the Go README: title, propagation-scope table, STEP markers,
  expected output for both scenarios
- dapr.yaml: appID=patient-app (was order-processor),
  resourcesPath=../../resources (was ../../components),
  appLogDestination/daprdLogDestination=console to match sister Python
  tutorials and Cassie's Go example
- Use correct Python SDK API names: get_last_workflow_by_name /
  get_last_activity_by_name (the earlier draft used get_workflow_by_name
  / get_activity_by_name, which were renamed in dapr/python-sdk#1025)

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants